package pe.edu.upc.dsd.epica.util;

import java.util.List;

import pe.edu.upc.dsd.epica.R;
import pe.edu.upc.dsd.epica.model.Promocion;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class PromocionAdapter extends ArrayAdapter<Promocion> {

	int resource;
	String response;
	Context context; // Initialize adapter

	public PromocionAdapter(Context context, int resource, List<Promocion> items) {
		super(context, resource, items);
		this.resource = resource;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LinearLayout promView;
		// Get the current alert object
		Promocion pro = getItem(position);

		if (convertView == null) {
			promView = new LinearLayout(getContext());
			String inflater = Context.LAYOUT_INFLATER_SERVICE;
			LayoutInflater vi;
			vi = (LayoutInflater) getContext().getSystemService(inflater);
			vi.inflate(resource, promView, true);
		} else {
			promView = (LinearLayout) convertView;
		}

		TextView promText = (TextView) promView
				.findViewById(R.id.txtDescripcion);

		promText.setText(pro.getDescripcion());
		return promView;
	}

}
